#include "server.h"

void save(char* buf)
{
	char path[PATH_LEN] = {};
	sprintf(path,"%s%s",ACC_PATH,ctos.acc.bank);

	int fd = open(path,O_RDWR);
	if(0 > fd)
	{
		error("open");
		sprintf(buf,"N:服务器正在升级，存款失败!");
		return;
	}

	Acc acc = {};
	read(fd,&acc,sizeof(Acc));

	acc.balance += ctos.acc.balance;
	lseek(fd,0,SEEK_SET);
	write(fd,&acc,sizeof(Acc));
	close(fd);

	sprintf(buf,"Y:存款成功，当前余额为:%g",acc.balance);
}
